package com.psq.business.login.ui.activity

import android.os.Bundle
import android.view.View
import cn.wufuqi.recyclerviewbindingadapter.utils.viewBindingActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.psq.business.login.R
import com.psq.business.login.databinding.LoginActivityLoginBinding
import com.psq.business.login.router.ROUTER_PATH_LOGIN
import com.psq.business.login.viewmodel.LoginViewModel
import com.psq.core.common.base.BaseActivity
import com.psq.core.common.base.BaseVMActivity
import com.psq.core.common.model.`do`
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = ROUTER_PATH_LOGIN)
class LoginActivity: BaseVMActivity<LoginViewModel>() {

    val binding by viewBindingActivity(LoginActivityLoginBinding::bind)

    override fun getLayoutResId() = R.layout.login_activity_login

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)




    }


    override fun doAfterView(savedInstanceState: Bundle?) {
        super.doAfterView(savedInstanceState)
        viewModel.loginLiveData.observe(this) {
            it.`do`({ user ->
                //登录成功
                viewModel.login(user)
                viewModel.navMain()
                finish()
            }, { _, errorMessage ->
               //登录失败
            })
        }
    }

}